home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995 August: Tool Chest / Dev.CD Aug 95 TC / Dev.CD Aug 95 TC.toast / Tool Chest / Interfaces / UniversalInterfaces 2.0 / PInterfaces / WorldScript.p < prev   
Encoding:
Text File  |  1995-04-18  |  9.5 KB  |  378 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        WorldScript.p
  3.  
  4.      Contains:    WorldScript I Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Package:    Universal Interfaces 2.0 in “MPW Latest” on ETO #17
  8.  
  9.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs@applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. }
  19.  
  20. {$IFC UNDEFINED UsingIncludes}
  21. {$SETC UsingIncludes := 0}
  22. {$ENDC}
  23.  
  24. {$IFC NOT UsingIncludes}
  25.  UNIT WorldScript;
  26.  INTERFACE
  27. {$ENDC}
  28.  
  29. {$IFC UNDEFINED __WORLDSCRIPT__}
  30. {$SETC __WORLDSCRIPT__ := 1}
  31.  
  32. {$I+}
  33. {$SETC WorldScriptIncludes := UsingIncludes}
  34. {$SETC UsingIncludes := 1}
  35.  
  36.  
  37. {$IFC UNDEFINED __TYPES__}
  38. {$I Types.p}
  39. {$ENDC}
  40. {    ConditionalMacros.p                                            }
  41.  
  42. {$IFC UNDEFINED __TRAPS__}
  43. {$I Traps.p}
  44. {$ENDC}
  45.  
  46. {$IFC UNDEFINED __QUICKDRAWTEXT__}
  47. {$I QuickdrawText.p}
  48. {$ENDC}
  49. {    MixedMode.p                                                    }
  50.  
  51. {$PUSH}
  52. {$ALIGN MAC68K}
  53. {$LibExport+}
  54.  
  55. CONST
  56.     kVariableLengthArray        = 1;
  57.  
  58.     
  59. TYPE
  60.     WSIOffset = UInt16;
  61.  
  62.     WSIByteCount = UInt8;
  63.  
  64.     WSIByteIndex = UInt8;
  65.  
  66. { offset from start of sub-table to row in state table }
  67.     WSIStateOffset = UInt16;
  68.  
  69.     WSITableOffset = UInt32;
  70.  
  71.     WSISubtableOffset = UInt16;
  72.  
  73.     WSIGlyphcode = UInt16;
  74.  
  75.     WSITableIdentifiers = UInt32;
  76.  
  77.  
  78. CONST
  79.     kScriptSettingsTag            = 'info';
  80.     kMetamorphosisTag            = 'mort';
  81.     kGlyphExpansionTag            = 'g2g#';
  82.     kPropertiesTag                = 'prop';
  83.     kJustificationTag            = 'kash';
  84.     kCharToGlyphTag                = 'cmap';
  85.     kGlyphToCharTag                = 'pamc';
  86.     kFindScriptRunTag            = 'fstb';
  87.  
  88. {***             L O O K U P    T A B L E    T Y P E S        ***}
  89.     WSILookupSimpleArray        = 0;                            { a simple array indexed by glyph code }
  90.     WSILookupSegmentSingle        = 2;                            { segment mapping to single value }
  91.     WSILookupSegmentArray        = 4;                            { segment mapping to lookup array }
  92.     WSILookupSingleTable        = 6;                            { sorted list of glyph, value pairs }
  93.     WSILookupTrimmedArray        = 8;                            { a simple trimmed array indexed by glyph code }
  94.  
  95.     
  96. TYPE
  97.     WSILookupTableFormat = INTEGER;
  98.  
  99.     WSILookupValue = INTEGER;
  100.  
  101. { An offset from the beginning of the lookup table }
  102.     WSILookupOffset = INTEGER;
  103.  
  104. {    FORMAT SPECIFIC DEFINITIONS }
  105. {
  106.         lookupSimpleArray:
  107.         
  108.         This is a simple array which maps all glyphs in the font
  109.         to lookup values.
  110.     }
  111.     WSILookupArrayHeader = RECORD
  112.         lookupValues:            ARRAY [0..0] OF WSILookupValue;            { The array of values indexed by glyph code }
  113.     END;
  114.  
  115. {
  116.         lookupTrimmedArray:
  117.         
  118.         This is a single trimmed array which maps a single range
  119.         of glyhs in the font to lookup values.
  120.     }
  121.     WSILookupTrimmedArrayHeader = RECORD
  122.         firstGlyph:                WSIGlyphcode;
  123.         limitGlyph:                WSIGlyphcode;
  124.         valueArray:                ARRAY [0..0] OF WSILookupValue;
  125.     END;
  126.  
  127. { The format specific part of the subtable header }
  128.     WSILookupFormatSpecificHeader = RECORD
  129.         CASE INTEGER OF
  130.         0: (
  131.             lookupArray:                WSILookupArrayHeader;
  132.            );
  133.         1: (
  134.             trimmedArray:                WSILookupTrimmedArrayHeader;
  135.            );
  136.     END;
  137.  
  138. { The overall subtable header }
  139.     WSILookupTableHeader = RECORD
  140.         format:                    WSILookupTableFormat;                    { table format }
  141.         fsHeader:                WSILookupFormatSpecificHeader;            { format specific header }
  142.     END;
  143.  
  144. {***        G L Y P H    E X P A N S I O N    ***}
  145.  
  146. CONST
  147. { fixed 1.0 }
  148.     kCurrentGlyphExpansionVersion = $00010000;
  149.  
  150.     
  151. TYPE
  152.     GlyphExpansionFormats = INTEGER;
  153.  
  154.  
  155. CONST
  156.     GlyphExpansionLookupFormat    = 1;
  157.     GlyphExpansionContextualFormat = 2;
  158.  
  159.  
  160. TYPE
  161.     ExpandedGlyphCluster = PACKED RECORD
  162.         numGlyphs:                WSIByteCount;
  163.         bestGlyph:                WSIByteIndex;
  164.         glyphs:                    ARRAY [0..0] OF WSIGlyphcode;
  165.     END;
  166.  
  167.     ExpandedGlyphOffset = RECORD
  168.         glyph:                    WSIGlyphcode;
  169.         offset:                    WSIOffset;                                { offset to ExpandedGlyphCluster }
  170.     END;
  171.  
  172.     GlyphExpansionStateTable = RECORD
  173.         stateTableOffset:        WSISubtableOffset;
  174.         classTableOffset:        WSISubtableOffset;
  175.         actionTableOffset:        WSISubtableOffset;                        { state, class and actions tables follow here... }
  176.     END;
  177.  
  178.     GlyphExpansionTable = RECORD
  179.         version:                Fixed;
  180.         format:                    INTEGER;
  181.         expansionNumer:            INTEGER;
  182.         expansionDenom:            INTEGER;                                { num/denom ratio for expansion <2> }
  183.         CASE INTEGER OF
  184.         0: (
  185.             stateTable:                    GlyphExpansionStateTable;
  186.            );
  187.         1: (
  188.             lookup:                        WSILookupTableHeader;                { expanded glyph clusters follow here... }
  189.            );
  190.     END;
  191.  
  192. { Glyph-to-Character constants and types  }
  193.  
  194. CONST
  195.     kCurrentGlyphToCharVersion    = $00010100;
  196.  
  197.     
  198. TYPE
  199.     GlyphToCharLookupFormats = INTEGER;
  200.  
  201.  
  202. CONST
  203.     kGlyphToCharLookup8Format    = 1;
  204.     kGlyphToCharLookup16Format    = 2;
  205.     kGlyphToCharLookup32Format    = 3;
  206.  
  207.     
  208. TYPE
  209.     GlyphToCharFontIndex = UInt8;
  210.  
  211.     QDGlyphcode = UInt8;
  212.  
  213.     GlyphToCharActionTable = RECORD
  214.         fontNameOffset:            WSISubtableOffset;                        { offset relative to this table }
  215.         actions:                WSILookupTableHeader;                    { only support lookupSimpleArray format for now }
  216.     END;
  217.  
  218.     GlyphToCharActionHeader = RECORD
  219.         numTables:                INTEGER;                                { 0..n }
  220.         offsets:                ARRAY [0..0] OF WSISubtableOffset;        { offsets from start of action table header }
  221.     END;
  222.  
  223.     GlyphToCharHeader = RECORD
  224.         version:                Fixed;
  225.         actionOffset:            WSISubtableOffset;                        { offset to GlyphToCharActionHeader }
  226.         format:                    INTEGER;                                { size of font mask }
  227.         mappingTable:            WSILookupTableHeader;
  228.     END;
  229.  
  230. { JUSTIFICATION TYPES
  231.     WorldScript supports justification of text using insertion. The justification
  232.     table specifies a insertion string to insert between 2 specified glyphs.
  233.     Each combination of inter-glyph boundary can be assigned a justification priority,
  234.     the higher the priority the more justification strings inserted at that position.
  235.     
  236.     The priorities for each inter-glyph boundary are specified by the justification table's
  237.     state table.
  238.     
  239.     Special handling is done for scripts which use spaces to justify, because the width of 
  240.     a space varies depending on the setting of SpaceExtra. This is why the number of spaces
  241.     per inserting string is specified in the justification table.
  242.  
  243. }
  244.  
  245. CONST
  246. { 1.0 not supported }
  247.     kCurrentJustificationVersion = $0200;
  248.  
  249.     kJustificationStateTableFormat = 1;
  250.  
  251. { WSI's internal limitation <12> }
  252.     kMaxJustificationStringLength = 13;
  253.  
  254.     
  255. TYPE
  256.     WSIJustificationPriority = UInt8;
  257.  
  258.  
  259. CONST
  260.     WSIJustificationSetMarkMask    = $80;
  261.  
  262.  
  263. TYPE
  264.     WSIJustificationStateEntry = PACKED RECORD
  265.         markPriority:            WSIJustificationPriority;                { non-zero priorities means insertion }
  266.         priority:                WSIJustificationPriority;
  267.         newState:                WSIStateOffset;
  268.     END;
  269.  
  270.     WSIJustificationClasses = INTEGER;
  271.  
  272.  
  273. CONST
  274.     wsiJustEndOfLineClass        = 0;
  275.     wsiJustEndOfRunClass        = 1;
  276.     wsiJustDeletedGlyphClass    = 2;
  277.     wsiJustUserDefinedClass        = 3;
  278.  
  279.     
  280. TYPE
  281.     WSIJustificationStates = INTEGER;
  282.  
  283.  
  284. CONST
  285.     wsiStartOfLineState            = 0;                            { pre-defined states }
  286.     wsiStartOfRunState            = 1;
  287.     wsiUserDefinedState            = 2;
  288.  
  289. { pre-multiplied: class# * sizeof(WSIJustificationStateEntry) }
  290.     
  291. TYPE
  292.     WSIJustificationClassOffset = UInt8;
  293.  
  294.     WSIJustificationStateTable = RECORD
  295.         maxPriorities:            INTEGER;
  296.         rowWidth:                INTEGER;                                { width of a state table row in bytes }
  297.         classTableOffset:        INTEGER;
  298.         stateTableOffset:        INTEGER;
  299.     END;
  300.  
  301.     WSIJustificationHeader = RECORD
  302.         version:                INTEGER;
  303.         format:                    INTEGER;
  304.         scaling:                Point;                                    { numer/denom scaling of priority weights <7> }
  305.         spacesPerInsertion:        INTEGER;                                { # of $20 chars in justification insertion string <12> }
  306.         justStringOffset:        INTEGER;                                { offset to justification string }
  307.         stateTable:                WSIJustificationStateTable;                { long-aligned boundary aligned w/ spacesPerInsertion field - justification string follows }
  308.     END;
  309.  
  310. { Line Layout's Property table version <11> }
  311.  
  312. CONST
  313. { v1.0 }
  314.     currentPropsTableVersion    = $00010000;
  315.  
  316. { ??? is this right }
  317.     kCharToGlyphCurrentVersion    = 0100;
  318.  
  319. { pass as priorityWeight to JustifyWSILayout to use script's current just setting }
  320.     kScriptsDefaultJustWeight    = -1;
  321.  
  322.  
  323. TYPE
  324.     WSIGlyphInfoRec = RECORD
  325.         qdChar:                    SInt8; (* UInt8 *)
  326.         rightToLeft:            SInt8;                                    { !0 means rightToLeft, 0 means leftToRight }
  327.         fontID:                    INTEGER;
  328.         originalOffset:            INTEGER;                                { or negative original offset if not in original text input }
  329.         unused:                    INTEGER;                                { long-align }
  330.     END;
  331.  
  332.     WSIGlyphInfoRecPtr = ^WSIGlyphInfoRec;
  333.     WSIGlyphInfoHandle = ^WSIGlyphInfoRecPtr;
  334.  
  335.     WSILayoutHandle = Handle;
  336.  
  337.  
  338. FUNCTION NewWSILayout(layoutH: WSILayoutHandle; text: Ptr; txLength: INTEGER; lineDirection: INTEGER; flags: LONGINT; VAR err: OSErr): WSILayoutHandle;
  339.     {$IFC NOT GENERATINGCFM}
  340.     INLINE $2F3C, $8414, $0040, $A8B5;
  341.     {$ENDC}
  342. FUNCTION JustifyWSILayout(layoutH: WSILayoutHandle; slop: Fixed; priorityWeight: INTEGER; styleRunPosition: JustStyleCode; numer: Point; denom: Point; VAR err: OSErr): WSILayoutHandle;
  343.     {$IFC NOT GENERATINGCFM}
  344.     INLINE $2F3C, $8418, $0042, $A8B5;
  345.     {$ENDC}
  346. FUNCTION MeasureWSILayout(layoutH: WSILayoutHandle; numer: Point; denom: Point): Fixed;
  347.     {$IFC NOT GENERATINGCFM}
  348.     INLINE $2F3C, $840C, $0044, $A8B5;
  349.     {$ENDC}
  350. PROCEDURE DrawWSILayout(layoutH: WSILayoutHandle; numer: Point; denom: Point);
  351.     {$IFC NOT GENERATINGCFM}
  352.     INLINE $2F3C, $800C, $0046, $A8B5;
  353.     {$ENDC}
  354. { "low-level" routines }
  355. FUNCTION GetWSILayoutParts(layoutH: WSILayoutHandle; destH: WSIGlyphInfoHandle; VAR numGlyphs: INTEGER; VAR err: OSErr): WSIGlyphInfoHandle;
  356.     {$IFC NOT GENERATINGCFM}
  357.     INLINE $2F3C, $8410, $0048, $A8B5;
  358.     {$ENDC}
  359. PROCEDURE DrawWSIGlyphs(length: INTEGER; qdCodes: Ptr; numer: Point; denom: Point);
  360.     {$IFC NOT GENERATINGCFM}
  361.     INLINE $2F3C, $800E, $004A, $A8B5;
  362.     {$ENDC}
  363. FUNCTION xMeasureWSIGlyphs(VAR qdCodes: Ptr; length: INTEGER; numer: Point; denom: Point): Fixed;
  364.     {$IFC NOT GENERATINGCFM}
  365.     INLINE $2F3C, $840E, $004C, $A8B5;
  366.     {$ENDC}
  367.  
  368. {$ALIGN RESET}
  369. {$POP}
  370.  
  371. {$SETC UsingIncludes := WorldScriptIncludes}
  372.  
  373. {$ENDC} {__WORLDSCRIPT__}
  374.  
  375. {$IFC NOT UsingIncludes}
  376.  END.
  377. {$ENDC}
  378.